package jk.zmn.thread.status;

import jdk.nashorn.internal.scripts.JO;

/**
 * @author 张梦楠
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2018/5/2615:20
 * @blog www.itzmn.com
 *
 *  线程阻塞方法
 *      当线程join时候，会执行完当前线程，然后执行被阻塞的线程
 *
 */
public class JoinTreadDemo1 extends Thread{

    public static void main(String[] args) throws InterruptedException {

        JoinTreadDemo1 demo = new JoinTreadDemo1();
        demo.start();

        for (int j=0;j<100;j++){
            if (j==50){
                demo.join();//main线程被阻塞，当demo这个线程结束之后才会执行main
            }
            System.out.println("main--"+j);
        }
     }

    @Override
    public void run() {
        for (int i=0;i<100;i++){
            System.out.println(Thread.currentThread().getName()+i);
        }
    }
}
